/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-02-17
*/
package com.rzico.basics.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.rzico.annotation.IgnoreSwaggerParameter;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;

/**
 * <pre>
 *   产品档案数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@Table(name = "wx_product_category")
@JsonIgnoreProperties(value = {"handler"})
public class ProductCategory{
    @ApiModelProperty(value = "")
    @Id
    protected Long id;

    @ApiModelProperty(value = "创建日期")
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期")
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "排序")
    protected Integer orders;

    @ApiModelProperty(value = "名称")
    protected String name;

    @ApiModelProperty(value = "树路径")
    protected String treePath;

    @ApiModelProperty(value = "")
    protected Long parentId;

    @ApiModelProperty(value = "")
    protected Long memberId;

    @ApiModelProperty(value = "缩略图")
    protected String thumbnail;

    @ApiModelProperty(value = "是否显示")
    protected Boolean isShow;

    @ApiModelProperty(value = "归属企业")
    protected Long enterpriseId;

    @ApiModelProperty(value = "创建者")
    protected String createBy;

    @ApiModelProperty(value = "更新者")
    protected String modifyBy;

    @ApiModelProperty(value = "子分类数组" ,hidden = true )
    @IgnoreSwaggerParameter
    private List<ProductCategory> childrens = new ArrayList<ProductCategory>();

    /**
     * 当前对象的直属父级
     */
    @JsonIgnore
    @IgnoreSwaggerParameter
    private ProductCategory parent;

    @ApiModelProperty(value = "上级分类名称", hidden = true)
    public String getParentName(){
        ProductCategory productCategory = getParent();
        if (null != productCategory){
            return productCategory.getName();
        }else{
            return "";
        }
    }
}
